﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using System.Web.UI.WebControls;
using System.Collections;
using System.Linq;

namespace ElectronicDiary.Models.Admin
{    
    public class StudentsClassEditAddModel
    {
        public int ID { get; set; }

        [Required(ErrorMessage = "{0} jest wymagany.")]
        [Display(Name = "Nauczyciel")]  
        public int IDTeacher { get; set; }

        [Required(ErrorMessage = "{0} jest wymagany.")]
        [Display(Name = "Profil")]  
        public string Profile { get; set; }

        [Required(ErrorMessage = "{0} jest wymagana.")]
        [Display(Name = "Klasa")]  
        public string Name { get; set; }

        [Required(ErrorMessage = "Data początku jest wymagana.")]
        [Display(Name = "Początek")]
        [DataType(DataType.Date)]
        public DateTime StartDate { get; set; }
        
        [Display(Name = "Koniec")]
        [DataType(DataType.Date)]
        public DateTime? EndDate { get; set; }

        public IEnumerable<SelectListItem> Teachers
        {
            get
            {
                using (var context = new electronicDiaryEntities())
                {
                    var collection = context.teacher.ToDictionary(n => n.idTeacher, n => n.firstName + " " + n.lastName);
                    IEnumerable<SelectListItem> sli;
                    sli = collection.Select(n => new SelectListItem
                    {
                        Value = n.Key.ToString(),
                        Text = n.Value
                    });
                    return sli;
                }
            }
        }
    }
}